//
//  RootVC.m
//  FilamentDemo
//
//  Created by 8000 on 2020/1/7.
//  Copyright © 2020 jerry. All rights reserved.
//

#import "RootVC.h"
#import "DrawCubeDemoVC.h"
#import "DrawCubeWithMaterialDemoVC.h"
#import "LoadGltfDemoVC.h"
#import "DrawLineVC.h"
@interface RootVC ()

@end

@implementation RootVC
{
    NSArray *_ds;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    _ds = @[
        @"画个立方体", NSStringFromSelector(@selector(drawCube)),
		@"画个立方体+材质", NSStringFromSelector(@selector(drawCubeWithMaterial)),
        @"加载gltf模型", NSStringFromSelector(@selector(loadGltfDemoVC)),
        @"画线", NSStringFromSelector(@selector(drawLine)),
    ];
    [self.tableView reloadData];
    
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [self drawLine];
  });
}
- (void)drawLine{
  DrawLineVC *vc = [[DrawLineVC alloc]init];
  [self.navigationController pushViewController:vc animated:YES];
}
- (void)loadGltfDemoVC{
    LoadGltfDemoVC *vc = [[LoadGltfDemoVC alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)drawCubeWithMaterial{
	DrawCubeWithMaterialDemoVC *vc = [[DrawCubeWithMaterialDemoVC alloc]init];
	[self.navigationController pushViewController:vc animated:YES];
}

- (void)drawCube{
	DrawCubeDemoVC *vc = [[DrawCubeDemoVC alloc]init];
	[self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _ds.count / 2;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.textLabel.text = _ds[indexPath.row * 2];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self performSelector:NSSelectorFromString(_ds[indexPath.row * 2 + 1])];
}

@end
